import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.xianzi = pygame.image.load("../资源/图片/仙子.jpg").convert_alpha()

        self.hero_pos = (5, 10)
        self.up_pos = (5, 0)
        self.variable_pos = {
            (5, 7): (self.door_yellow, '黄门'),
            (5, 8): (self.xianzi, '仙子')
        }

    def fixed_brick(self):
        for i in range(11):
            for j in range(11):
                if i != 5 and (i, j) not in [(4, 8), (6, 8)]:
                    self.draw(self.wall, i, j)
                    self.dic[(i, j)] = '墙'
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'

#     def loop(self):
#         while True:  # 主循环
#             for event in pygame.event.get():
#                 if event.type is pygame.QUIT:
#                     sys.exit()  # 按键响应，按键后退出
#             self.screen.fill(self.black)  # 填充背景
#             a = len(self.ls)
#             # 画墙
#             self.fixed_brick()
#             b = len(self.ls)
#             if a == b:      # 判断墙是否画完
#                 self.variable_brick()
#             self.draw_hero()
#             pygame.display.update()     # 刷新
#
#
# if __name__ == '__main__':
#     Map().loop()      # 查看地图
